#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int num = 0;
	vector<int> ret;
	while (cin >> num)
	{
		ret.push_back(num);
	}

	sort(ret.begin(), ret.end());

	int s1 = 0, s2 = -1;

	for (int i = 0; i < ret.size()-1; i++)
	{
		if (ret[i] == ret[i + 1]) s2 = ret[i];

		if (ret[i + 1] - ret[i] > 1) s1 = ret[i] + 1;
	}

	cout << s1 << " " << s2 << endl;
	return 0;
}